home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CVoice 1.2 / CVoice.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.7 KB  |  104 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CVoice.h        Version1.2
  3.  
  4.  Written by Brian Stern  <Jaeger@fquest.com>
  5.  
  6.  Written to work with TCL 2.x
  7.  
  8.      Interface file for CVoice.
  9.      
  10.     This class is Copyright © 1994, Brian Stern.  It may be used freely in 
  11.     any projects.  If you do anything interesting with it send me email.
  12.  
  13. ******************************************************************************/
  14.  
  15. #pragma once
  16.  
  17. #include <Speech.h>
  18.  
  19. #define kPtrLen     256L
  20. #define kNoSpManErr    -1
  21. #define kBadChanErr -2
  22. #define kTruncErr    -3
  23.  
  24. enum {
  25.     kTextInput,
  26.     kPhonInput
  27. };
  28.  
  29. enum voicetype{
  30.     knotInited,
  31.     kHasSpeechMan,
  32.     kNoHasSpeechMan
  33. };
  34.  
  35.  
  36. class CVoice 
  37. {        
  38.  
  39. protected:
  40.                                 /** Instance Variables **/
  41.     SpeechChannel        ftheChannel;        //Speech channel for this voice
  42.     VoiceSpec            ftheSpec;            //VoiceSpec for this voice
  43.     Boolean                fGoodChannel;        //Did the speech channel initialize OK?
  44.     Ptr                    fTextPtr;            //Buffer for text to be spoken
  45.     long                fTextPtrSize;        //Current size of the buffer
  46.     long                fInputFormat;        //Speaking in text or phonemic format
  47.     short                fCurrVoiceItem;        //Item number of the voice name in Voice menu
  48.  
  49. static    voicetype        cHasSpeechMan;        //Class variable for presence of Speech Manager
  50. static    short            cVoiceMenuID;        //Class variable for ID of Voice Menu if used
  51.  
  52. public:
  53.                                 /** Instance Methods **/
  54.  
  55.                             CVoice(void);
  56.                             CVoice( const Str63 theVoice );
  57.     virtual                 ~CVoice();
  58.     
  59.     virtual Boolean            HasSpeechMan( void ) { return cHasSpeechMan == kHasSpeechMan; }
  60.  
  61.     virtual OSErr            SetVoice( const Str63 theVoice );
  62.     
  63.     virtual OSErr            SpeakTheText( const char *theText, long len );
  64.     virtual OSErr            SpeakThePhonemes( const char *theText, long len );
  65.  
  66.     virtual Handle            GetPhonemeInfo( void );
  67.  
  68.     virtual OSErr            GetDescription( VoiceDescription *theDesc ) const;
  69.  
  70.     virtual void            GetVSpec( VoiceSpec *theVSpec ) const;
  71.  
  72.     virtual OSErr            WordToPhoneme( const Str255 theWord, Str255 thePhoneme );
  73.  
  74.     virtual OSErr            StopSpeaking( long whentostop );
  75.     virtual OSErr            PauseSpeaking( long whentostop );
  76.     virtual OSErr            ContinueSpeaking(void);
  77.  
  78.     virtual Boolean            AreWeSpeaking(void);
  79.     virtual Boolean            AreAnySpeaking(void);
  80.     virtual Boolean            AreWePaused(void);
  81.  
  82.     virtual short            NumVoices(void);
  83.     virtual OSErr            GetVoicebyIndex( long index, Str63 theName );
  84.  
  85.     virtual OSErr            BuildVoiceMenu( short theMenuID );
  86.     virtual OSErr            SetVoiceFromMenu( long theCommand );
  87.     virtual void            UpdateMenus(void);
  88.  
  89.     virtual OSErr            UseADictionary( Handle thedict );
  90.  
  91. protected:
  92.  
  93.     virtual OSErr            SpeakIt( const char *theText, long len, short inputType );
  94.     
  95.     virtual void            SetInputFormat( short inputFormat );
  96.  
  97.     virtual short            FindVoiceItemNum( const Str63 theVoice );
  98.  
  99. private:
  100.  
  101.     void    InitVoice( void );
  102.     
  103. };
  104.